import request from '@/utils/request'

/**
 * 用户列表
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} data
 * @returns
 */
export function listUser (data) {
  return request({
    url: '/v1/user/list',
    method: 'post',
    data
  })
}

/**
 * 用户详情
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} userId
 * @returns
 */
export function getUser (userId) {
  return request({
    url: '/v1/user/' + userId,
    method: 'get'
  })
}
/**
 * 冻结/解冻用户
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} user_id 用户ID
 * @param {*} status 状态
 * @returns
 */
export function freezeUser (user_id, status) {
  return request({
    url: '/v1/user/freeze',
    method: 'put',
    data: { user_id, status }
  })
}

/**
 * 用户注销
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} userId 用户ID
 * @returns
 */
export function delUser (userId) {
  return request({
    url: '/v1/user/' + userId,
    method: 'delete'
  })
}

/**
 * 用户注销/冻结/解冻
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} user_id 用户ID
 * @param {*} status 状态
 */
export function updateStatus (user_id, status) {
  if (status === 2) { // 注销
    delUser(user_id)
  } else { // 冻结、解冻
    freezeUser(user_id, status)
  }
}
/**
 * 验证用户列表
 * http://192.168.88.247:4999/web/#/14/1816
 * @param {*} params
 * @returns
 */
export function userAuthList (params) {
  return request({
    url: '/us/api/v1/userauth/userlist',
    method: 'get',
    params
  })
}
/**
 * 审核用户
 * http://192.168.88.247:4999/web/#/14/1817
 * @param {*} data
 * @returns
 */
export function auditUser (data) {
  return request({
    url: '/us/api/v1/userauth/audit',
    method: 'put',
    data
  })
}

export function createExportUserTask (data) {
  return request({
    url: '/v1/user/export',
    method: 'post',
    data
  })
}

export function queryExportUserTask (params) {
  return request({
    url: '/v1/user/export_task',
    method: 'get',
    params
  })
}
